<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script type="text/dialog">
	$('#categoryAddForm').validate({
		errorElement: 'div',
		errorClass: 'help-block',
		focusInvalid: false,
		rules: {
			name:{
				required: true
			},
			seq:{
				required:true,
				number:true
			}
		},
		highlight: function (e) {
			$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
		},
		success: function (e) {
			$(e).closest('.form-group').removeClass('has-error');//.addClass('has-info');
			$(e).remove();
		},submitHandler: function(form) {  
              $(form).ajaxSubmit({
					beforeSubmit: showRequest,
					success:       showResponse
			});  
        },  
		errorPlacement: function(error, element) {
			if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
		}
	});

function showRequest(formData, jqForm, options){
 	var queryString = $.param(formData);
 	art.dialog({id:'uploadDialog',title:'正在处理...',content:'<img src="../resources/admin/assets/images/loading2.gif">&nbsp;&nbsp;处理中，请稍后...',width:'250px',height:'120px',lock:true,background:'#ccc'});
 	return true;
 }
 function showResponse(data){
 	art.dialog.list['uploadDialog'].close();
 	if(data.success){
 		$(".error-text").html("");
		art.dialog({id:'categoryEditDialog'}).close();
		art.dialog({content:data.msg,resize:true,time:2,icon:'succeed',ok:function(){this.close()}});
		$('#CategoryTable').DataTable().draw() ;		//重新刷新数据表格
 	}else{
 		$(".error-text").html(data.msg);
		return;
 	}
 }
</script>
<div class="scheduleBox">
	<h3 class="lighter block green">编辑产品类别</h3>
	<form class="form-horizontal" role= "form" id="categoryAddForm" name="categoryAddForm" method="post" action="${pageContext.request.contextPath}/product/category/categoryEdit.do">
		<input type="hidden" name="id" value="${pCate.id}">
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 类别名称: </label>
			<div class="col-sm-8">
				<input type="text" id="name" class="col-sm-7" name="name" value="${pCate.name}"/>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 显示顺序: </label>
			<div class="col-sm-8 ">
				<input type="text"  class="col-sm-6" id="seq" name="seq" value="${pCate.seq}"/>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 备注: </label>
			<div class="col-sm-8 ">
				<input type="text"  class="col-sm-12" id="remark" name="remark" value="${pCate.remark}"/>
			</div>
		</div>
		
		<div class="form-group">
			<div class="col-sm-4">
				<button type="submit" class="btn btn-sm btn-success">
				保存
				<i class="ace-icon fa fa-pencil bigger-110"></i>
				</button>
			</div>
		</div>
		
	</form>
</div>